package com.zhiyou100.review.day019.homework;

/**
 * @packageName: Homework2
 * @className: com.zhiyou100.review.day019.homework
 * @Description: TODO 2 模拟五个学生给一个老师每人交3本作业
 * @author: yang
 * @date: 6/30/20
 */
public class Homework2 {
    public static void main(String[] args) {
        Student student = new Student();
        // 创建一个实现类对象
        Thread thread1 = new Thread(student, "张三");
        Thread thread2 = new Thread(student, "李四");
        Thread thread3 = new Thread(student, "王舞");
        Thread thread4 = new Thread(student, "洛璃");
        Thread thread5 = new Thread(student, "王富贵");
        // 创建5个线程，五个线程对象的线程完全一样
        thread1.start();
        thread2.start();
        thread3.start();
        thread4.start();
        thread5.start();

    }
}

class Teacher {
    int number = 0;
}

class Student implements Runnable {
    /**
     * 五个学生同时给一个老师交3本作业
     */
    static Teacher teacher = new Teacher();

    @Override
    public void run() {
        int max = 3;
        for (int i = 0; i < max; i++) {
            teacher.number++;
            System.out.println(Thread.currentThread().getName() + " 交第" + i + "本作业：：：，老师作业总数" + teacher.number);
        }
    }
}